<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="file" name="md" id="file-warp" multiple="multiple">
<input type="button" value="确定" id="submit-btn">
<script src="jquery.min.js"></script>
<script>
    $(function () {
        $("#submit-btn").click(function () {
            var files = $("#file-warp")[0].files;
            var formData = new FormData();
            //将文件属性放入 formData 里面
            for (var i = 0; i < files.length; i++) {
                formData.append("files", files[i], files[i].name);
            }
            $.ajax({
                url: '/import',
                type: 'post',
                async: false,
                data: formData,
                processData: false,// 告诉jQuery不要去处理发送的数据
                contentType: false,// 告诉jQuery不要去设置Content-Type请求头
                beforeSend: function () {
                    console.log('正在进行，请稍候')
                },
                success: function (res) {
                    if (res.code === 0) {
                        console.log('上传成功')
                    } else {
                        console.log('上传失败')
                    }
                },
                error: function () {
                    console.log('上传失败')
                }
            })
        })

    })
</script>
</body>
</html>